home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld Secrets (4th Edition)
/
Mac Secrets CD 4th Ed.toast
/
Apple Advanced Technologies
/
Apple Speech Technologies 1.5
/
PlainTalk Developer Info
/
Speech Recognition Manager SDK
/
SR Sample Code
/
IM SR Example
/
MyCallPersonInPath.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-04-10
|
2KB
|
54 lines
#include <SpeechRecognition.h>
#include <stdio.h>
OSErr MyCallPersonInPath (SRPath recognizedPath);
/*
const char * kPersonNames[] = {"Arlo", "Matt", "Brent", "my wife", NULL};
*/
extern const char * kPersonNames[];
const char * kPhoneNumbers[] = {"555-4567", "555-4568", "555-4569",
"(123) 456-7890"};
OSErr MyCallPersonInPath (SRPath recognizedPath)
{
OSErr myErr = noErr;
SRLanguageObject myPersonLM;
/* recognizedPath has two sub-elements: */
/* "<call>" (SRLanguageModel), "<person>" (SRLanguageModel) */
/* we get the second sub-element */
myErr = SRGetIndexedItem (recognizedPath, &myPersonLM, 1);
if (!myErr) {
SRLanguageObject myPhraseSpoken;
/* myPersonLM will have one sub-element, the name spoken (a phrase) */
myErr = SRGetIndexedItem (myPersonLM, &myPhraseSpoken, 0);
if (!myErr) {
long myRefCon;
Size myLen = sizeof (myRefCon);
/* When we built the language model, we set the refcon to the index */
/* of names in a list. The phone numbers in kPhoneNumbers correspond */
/* to those names */
myErr = SRGetProperty (myPhraseSpoken, kSRRefCon, &myRefCon, &myLen);
if (!myErr) {
short myArrayIndex = myRefCon;
printf ("Now calling %s. Dialing %s.\n",
kPersonNames[myArrayIndex], kPhoneNumbers[myArrayIndex]);
}
/* release myPhraseSpoken when done with it */
myErr = SRReleaseObject (myPhraseSpoken);
}
/* release myPersonLM when done with it */
myErr = SRReleaseObject (myPersonLM);
}
return myErr;
}